package ziyu.task.dispath.core.java.test;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Test4 {
	public static BigDecimal writeInDB3(String path) {
		BigDecimal count = new BigDecimal("0.00");
		try {
			DataInputStream in = new DataInputStream(new FileInputStream(new File(path)));
			BufferedReader br = new BufferedReader(new InputStreamReader(in, "GBK"));
			List<String> dataList = new ArrayList<String>();
			String line;
			//JdbcUtils jdbc = new JdbcUtils();
			
			while ((line = br.readLine()) != null) {
				String t1 =  line.split(",")[6];
				BigDecimal cat1 =new BigDecimal( line.split(",")[6]);
				count = count.add(cat1);				
			}
			//System.out.println();
			br.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return count;
	}
	public static void main(String[] args) {
		BigDecimal cBigDecimal = new BigDecimal("0.00");
		//writeInDB3("C:\\Users\\ziyu\\Desktop\\abc\\30\\QD01_paylog_20161123_001.txt");
		String file_path = "C:\\Users\\ziyu\\Desktop\\abc\\30\\";
		int i =0;
		File file = new File(file_path);
		if(!file.exists()){
			System.out.println("路径不存在");
		}else{
			File[] files = file.listFiles();
			i = files.length;
			//
		}
		//System.out.println("包含文件个数="+i);
		for (int j =1; j <= i; j++) {
			System.out.println(j);
			cBigDecimal=cBigDecimal.add(writeInDB3("C:\\Users\\ziyu\\Desktop\\abc\\30\\QD01_paylog_20161123_00"+j+".txt"));
			
		}
		System.out.println(cBigDecimal);
	}
}
